package com.easy.web.api;

import com.easy.common.check.SVFilter;
import com.easy.common.core.R;
import com.easy.common.core.domain.model.LoginBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 敏感 词汇 校验 pai
 *
 * @author RuoYu
 * @date 2022/12/07
 */
@RestController
@RequestMapping
@Api(tags = "敏感 词汇 校验 控制器")
public class SVControllerApi {

    @Autowired
    private SVFilter svFilter;

    /**
     * 使用百度接口
     *
     * @param msg 校验信息
     * @return {@link R}
     */
    @GetMapping("sv/{msg}")
    @ApiOperation(value = "使用百度敏感词汇接口")
    @ApiImplicitParam(name = "msg", value = "要校验的信息", dataTypeClass = String.class, required = true)
    public R sv(@PathVariable String msg) {
        System.out.println(msg);
        String sv = svFilter.sv(msg);
        if (sv.equals("不合规")) {
            return R.error("存在低俗辱骂不合规");
        }
        return R.success(sv);
    }

}
